import org.deschutter.dump.AllianceDump;
import org.deschutter.dump.GalaxyDump;
import org.deschutter.dump.PlanetDump;
import org.deschutter.Constants;

/**
 * User: berten
 * Date: Jan 26, 2010
 * Time: 9:47:36 PM
 */
public class Digger2 implements Constants{
     public static void main(String[] args) throws Exception {
args = new String[] {"597-602"};
         if (args == null || args.length == 0) {
            AllianceDump.runTickDump(ALLIANCE_LISTING_URL);
            GalaxyDump.runTickDump(GALAXY_LISTING_URL);
            PlanetDump.runTickDump(PLANET_LISTING_URL);
        } else if (args[0].contains("-") && args[0].indexOf("-") == args[0].lastIndexOf("-")) {
               String[] oi = args[0].split("-");
               try {
                   int a = Integer.parseInt(oi[0]);
                   int b = Integer.parseInt(oi[1]);
                   for( int z = a;z<=b;z++) {
                    AllianceDump.runTickDump("http://www.sandmans.co.uk/dumps/all/" + String.format("%04d", new Object[]{new Integer(z)}) + "-alliance_listing.txt");
                    GalaxyDump.runTickDump("http://www.sandmans.co.uk/dumps/all/" + String.format("%04d", new Object[]{new Integer(z)}) + "-galaxy_listing.txt");
                    PlanetDump.runTickDump("http://www.sandmans.co.uk/dumps/all/" + String.format("%04d", new Object[]{new Integer(z)}) + "-planet_listing.txt");

                   }

               }   catch(Exception e) {

               }

        } else if (args[0].contains(",")) {
                String[] ticklist = args[0].split(",");
           for(int a=0;a<ticklist.length;a++) {
                    AllianceDump.runTickDump("http://www.sandmans.co.uk/dumps/all/" + String.format("%04a", new Object[]{new Integer(ticklist[a])}) + "-alliance_listing.txt");
                    GalaxyDump.runTickDump("http://www.sandmans.co.uk/dumps/all/" + String.format("%04a", new Object[]{new Integer(ticklist[a])}) + "-galaxy_listing.txt");
                    PlanetDump.runTickDump("http://www.sandmans.co.uk/dumps/all/" + String.format("%04a", new Object[]{new Integer(ticklist[a])}) + "-planet_listing.txt");
           }
        } else {
            try {
               int ticktodump = Integer.parseInt(args[0]);
                AllianceDump.runTickDump("http://www.sandmans.co.uk/dumps/all/" + String.format("%04d", new Object[]{new Integer(ticktodump)}) + "-alliance_listing.txt");
                GalaxyDump.runTickDump("http://www.sandmans.co.uk/dumps/all/" + String.format("%04d", new Object[]{new Integer(ticktodump)}) + "-galaxy_listing.txt");
                PlanetDump.runTickDump("http://www.sandmans.co.uk/dumps/all/" + String.format("%04d", new Object[]{new Integer(ticktodump)}) + "-planet_listing.txt");
            }
            catch (Exception e) {
                System.out.println("Not a number");
            }
        }
    }
}